package com.cabal.module.log.service.impl;

import com.cabal.common.util.SnowflakeIdUtil;
import com.cabal.common.util.TmsServiceException;
import com.cabal.module.log.dao.RequestMessageLogMapper;
import com.cabal.module.log.entity.RequestMessageLog;
import com.cabal.module.log.service.IRequestMessageLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.Date;

/**
 * 请求用户信息
 *
 * @author shenkang
 * @data 2022年4月25日
 */
@Slf4j
@Service
public class RequestMessageLogServiceImpl implements IRequestMessageLogService {

    @Resource
    private RequestMessageLogMapper requestMessageLogMapper;

    @Override
    public void insertRequestMessageLog(RequestMessageLog requestMessageLog) throws TmsServiceException {
        long id = SnowflakeIdUtil.getInstance().nextId();
        requestMessageLog.setId(id);
        requestMessageLog.setRequestTime(new Timestamp(new Date().getTime()));
        requestMessageLogMapper.insert(requestMessageLog);
    }
}
